﻿namespace N2.Workflow.Items
{
	using Details;
	using Integrity;

	/// <summary>
	/// A single 1:1 mapping between
	/// a Workflow definition and a Content Item Type for which this workflow
	/// should be considered.
	/// </summary>
	[Definition]
	[RestrictParents(typeof(WorkflowRepository))]
	public sealed class WorkflowBindingByContainer: WorkflowBinding
	{
		#region Properties

		public override string IconUrl { get { return Constants.IconPath + "workflow_link.png"; } }

		/// <summary>
		/// Container, which children should be associate with a workflow definition
		/// </summary>
		[EditableLink("Item Container", 2)]
		public ContentItem Container {
			get { return this.GetDetail<ContentItem>("Container", null); }
			set { this.SetDetail<ContentItem>("Container", value); }
		}

		protected override string GetCaption()
		{
			return
				base.GetCaption() + " for " +
					(null != this.Container
						? this.Container.Title + "#" + this.Container.ID
						: "?");
		}

		#endregion Properties
	}
}
